home *** CD-ROM | disk | FTP | other *** search
/ Floppyshop 2 / Floppyshop - 2.zip / Floppyshop - 2.iso / diskmags / 3565-4.665 / dmg-4180 / a / a13.doc < prev    next >
Text File  |  1987-04-21  |  5KB  |  195 lines

  1.  
  2.           UNDERSTANDING STOS
  3.      Copied from the STOS Magazine
  4.   Thanks to Dion Guy who retains the
  5.       Copyright to this Article
  6.  
  7. Here is the  final  part  of  our  A-Z 
  8. variable guide (see issues 1+2).We also 
  9. have a bit more on using  variables  in 
  10. your  programs.  
  11.  
  12. SGN(num var)
  13.   SGN  is used to find the  SIGN  of a 
  14. number.The result will equal -1 if the 
  15. number is negative,0 if the  number is 
  16. zero and 1 if the number is positive.Eg 
  17.  {A=10:print SGN (A)} will display 1 as 
  18. a result.
  19.  
  20. SORTdimensioned var or num var(startpos)
  21.   SORT can sort through your array  and 
  22. put  the contents into  ascending order 
  23. for   you.   It  does  this  relatively 
  24. fast.For example if you  have  an array 
  25. of 10  numbers,say NUM,that you  wanted  
  26. to sort into ascending order you  would 
  27. just use-sort NUM(0). The number in the 
  28. brackets  indicates  the  place  in the 
  29. array to start sorting from(usually 0). 
  30. Type in this program to see sort in use.
  31.  
  32. 10 dim NUM (10)
  33. 20 for A=1 to 10
  34. 30 B=rnd(100)
  35. 40 NUM(A)=B
  36. 50 next A
  37. 60 sort NUM(0)
  38. 70 for A=1 to 10
  39. 80 print NUM (A)
  40. 90 next A
  41. 100 end
  42.  
  43.   This  program  will  pick ten  random 
  44. numbers from between 1 and 100 and 
  45. store them in the NUM array. We then use  
  46. the sort command to sort  these  random 
  47. numbers into ascending order. Lastly we 
  48. print  the numbers so you can see  sort 
  49. has done its job.SORT is mainly used in 
  50. conjunction with MATCH which allows you 
  51. to find the closest match to a 
  52. specified variable within an array.  
  53. See MATCH for further details.
  54.  
  55. SPACE$(number of spaces)
  56.   This  is a reserved  variable  which 
  57. allows you to add spaces to a string 
  58.  or display spaces on screen. Eg :
  59. 10 print "Hello";SPACE$(5);"there"
  60. or
  61. 10 A$="Hello"
  62. 20 A$=A$+space$(5):A$=A$+"there" 
  63. 30 print A$
  64.  
  65. STR$ (num var)
  66.   STR$  converts a number to  a string. 
  67. This  is useful for using  the `centre` 
  68. command as centre does not allow you to 
  69. display number variables etc. Eg:
  70. 10 A=4
  71. 20 home:centre " STOS  Magazine  issue" 
  72.  +str$(A)+" is  here !"
  73. or another use:
  74. 10 A=68000
  75. 20 print A
  76. 30 A$= str$(A):print A$
  77.  The opposite,VAL,allows you to convert 
  78. a string to a number. See VAL.
  79.  
  80. STRING$ (var,length)
  81.  STRING$ can be used to create a string, 
  82. length    characters    long,containing 
  83. nothing  but the first character of the 
  84. specified     string.      Eg:    print 
  85. STRING$("HAT",10) -will display 10 H's.
  86.  
  87. SWAP (var/num var,var/num var)
  88.   This simply SWAPs the  information of 
  89. two  variables(of the same type)around. 
  90. Eg :
  91. 10 A=10:B=20
  92. 20 swap A,B
  93. 30 print A,B
  94.  
  95. TIME$
  96.   TIME$  is a string that  STOS updates 
  97. every 50th of a second,and contains how 
  98. long ,in hours,minutes and seconds that 
  99. STOS  has been running.  The  format of 
  100. this variable is"hours:minutes:seconds" 
  101. and  can be set with a command such as: 
  102. TIME$="01:20:30".  This  would  set the 
  103. clock  to  1  hour,20  minutes  and  30 
  104. seconds.
  105.  
  106. TIMER
  107.   TIMER  is another variable  that STOS 
  108. updates  every  50th  of  a  second,and 
  109. represents   how  long  STOS  has  been 
  110. running.  The  format is different from 
  111. TIME$ though as this contains the 
  112. actual 50th's of a second STOS has been 
  113. running.  Eg - if STOS has been running 
  114. for 2 minutes,  TIMER would contain the 
  115. number 6000. You can alter TIMER in the 
  116. same  way  as you can alter  any  other 
  117. number  variable.  Eg  - TIMER=0.  This 
  118. reserved  variable can be used  to time 
  119. program execution times,program loops 
  120. or can be used as an in game/program 
  121. timer.
  122.  
  123. TRUE
  124.   TRUE  is basically a  number variable 
  125. that always contains the number -1. The 
  126. TRUE   command  can  be  used  to  make 
  127. decisions as to whether things are true 
  128. or false. Eg :
  129. 10  A=10:if A>0=TRUE then print "{A} is 
  130. higher than zero"
  131. See FALSE
  132.  
  133. UPPER$
  134.   UPPER$ is used to display a string in 
  135. upper case letters,even if the string 
  136. is in lower case letters.  Eg  -  print 
  137. UPPER$("lower") -will display `LOWER `. 
  138. Another example:
  139. 10 A$="Hello"
  140. 20 A$=upper$(a$)
  141. 30 print A$
  142. See LOWER$
  143.  
  144. VAL(var)
  145.  VAL is used to convert a string into a 
  146. number variable. Eg :
  147. 10 A$="10"
  148. 20 A=VAL(A$)
  149. 30 print A
  150. See STR$
  151.  
  152. XGRAPHIC(num var)
  153.   This  command  is very  useful  as it 
  154. converts  a X text coordinate into a  X 
  155. graphic   coordinate.    Eg   -   print 
  156. XGRAPHIC(2)  {from  the  standard  STOS 
  157. editor  window} - will return  16. This 
  158. command   {and  YGRAPHIC}   takes  into 
  159. account if you are in a window.
  160. See YGRAPHIC
  161.  
  162. XMOUSE
  163.   XMOUSE  is a reserved  variable which 
  164. holds  the  X  position  of  the  mouse 
  165. cursor. Eg - {print XMOUSE}.See YMOUSE
  166.  
  167. XTEXT(num var)
  168.   XTEXT is the opposite of  XGRAPHIC in 
  169. that it converts Xgraphic coordinations 
  170. into  X  text coordinates.  Eg  - print 
  171. XTEXT(16){from the standard STOS editor 
  172. window}  - will return 2.  This command 
  173. {and  YTEXT} takes into account if  you 
  174. are in a window. See YTEXT
  175.  
  176. YGRAPHIC(num var)
  177.    The   Y  coordinate   equivalent  of 
  178. XGRAPHIC. See XGRAPHIC.
  179.  
  180. YMOUSE
  181.  The Y coordinate equivalent of XMOUSE. 
  182. See XMOUSE
  183.  
  184. YTEXT(num var)
  185.   The Y coordinate equivalent of XTEXT. 
  186. See XTEXT.
  187.       
  188.                
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.